<%--***************************************
*
*易宝支付
* 
***************************************--%>
<%@ page import="
	java.util.*,
	java.text.*,
	com.probiz.estore.common.model.order.SalesOrder,
	com.probiz.estore.common.model.system.PaymentGateway,
	com.probiz.estore.system.util.TranslateService,
	com.probiz.estore.common.helper.ConfigUtil"
	contentType="text/html; charset=UTF-8"%>
<%
	request.setCharacterEncoding("GBK");

	SalesOrder salesOrder = (SalesOrder) request.getAttribute("salesOrder");
	PaymentGateway paymentGateway = (PaymentGateway) request.getAttribute("paymentGateway");
	request.setAttribute("paymentGateway",paymentGateway);
	HashMap paramMap = paymentGateway.getConfigData();
	
	//-----------------------start: 账户信息------------------------------------------
	String p1_MerId ="";
	String encryptionKey="";
	if (paramMap != null) {
		p1_MerId = paramMap.get("merchantId").toString().trim(); 			//商户号
		encryptionKey = paramMap.get("encryptionKey").toString().trim(); 	//密钥
	}
	//-----------------------end:   账户信息------------------------------------------
	
	//-----------------------start: 配置信息------------------------------------------
	String p8_Url = ConfigUtil.getInstance().getStoreFrontSiteUrl()+"/system/payment/yeepay_response.html";  //支付成功后易宝支付会向该地址发送两次成功通知，该地址可以带参数
	
	//-----------------------end:   配置信息------------------------------------------
	
	//-----------------------start:	业务信息------------------------------------------
	DecimalFormat df=new DecimalFormat("0.00");
	String p0_Cmd= "Buy";											//业务类型 固定值“Buy”
	String p2_Order = salesOrder.getOrderNo();						//商户订单号.易宝支付系统中对于已付或者撤销的订单，商户端不能重复提交。
	String p3_Amt = df.format(salesOrder.getUnPaidAmount());		//支付金额,单位:元，精确到分
	String p4_Cur = "CNY";											// 交易币种
	String p5_Pid= "order:"+salesOrder.getOrderNo();				//商品名称
	String p6_Pcat= "";												//商品种类
	String p7_Pdesc= "order:"+salesOrder.getOrderNo();				//商品描述
	String p9_SAF= "0";												//送货地址 不需要为0
	String pa_MP = "";												//商户扩展信息 返回时原样返回，此参数如用到中文，请注意转码.
	String pd_FrpId = "";											//支付通道编码
	String pr_NeedResponse = "1";									//固定值为“1”: 需要应答机制; 收到易宝支付服务器点对点支付成功通知，必须回写以”success”（无关大小写）开头的字符串，即使您收到成功通知时发现该订单已经处理过，也要正确回写”success”，否则易宝支付将认为您的系统没有收到通知，启动重发机制，直到收到”success”为止。
	
	StringBuffer crackText = new StringBuffer();
	crackText.append(p0_Cmd);
	crackText.append(p1_MerId);
	crackText.append(p2_Order);
	crackText.append(p3_Amt);
	crackText.append(p4_Cur);
	crackText.append(p5_Pid);
	crackText.append(p6_Pcat);
	crackText.append(p7_Pdesc);
	crackText.append(p8_Url);
	crackText.append(p9_SAF);
	crackText.append(pa_MP);
	crackText.append(pd_FrpId);
	crackText.append(pr_NeedResponse);

	String hmac = TranslateService.hmacMd5Transalte(crackText.toString(),encryptionKey);
	//-----------------------end:	业务信息------------------------------------------
	
%>
<div style="display:none;">
	<form name="paymentGatewayForm" action="https://www.yeepay.com/app-merchant-proxy/node" method="post">
		<input type="hidden" name="p0_Cmd" value="<%=p0_Cmd%>">
		<input type="hidden" name="p1_MerId" value="<%=p1_MerId%>">
		<input type="hidden" name="p2_Order" value="<%=p2_Order%>">
		<input type="hidden" name="p3_Amt" value="<%=p3_Amt%>">
		<input type="hidden" name="p4_Cur" value="<%=p4_Cur%>">
		<input type="hidden" name="p5_Pid" value="<%=p5_Pid%>">
		<input type="hidden" name="p6_Pcat" value="<%=p6_Pcat%>">
		<input type="hidden" name="p7_Pdesc" value="<%=p7_Pdesc%>">
		<input type="hidden" name="p8_Url" value="<%=p8_Url%>">
		<input type="hidden" name="p9_SAF" value="<%=p9_SAF%>">
		<input type="hidden" name="pa_MP" value="<%=pa_MP%>">
		<input type="hidden" name="pd_FrpId" value="<%=pd_FrpId%>">
		<input type="hidden" name="pr_NeedResponse"  value="<%=pr_NeedResponse%>">
		<input type="hidden" name="hmac" value="<%=hmac%>">
	</form>
</div>
	
<script type="text/javascript">
$j(document).ready(function () {
	document.forms["paymentGatewayForm"].submit();
});
</script>

<%@ include file="./include/payOrderTips.jspf" %>